import { createRouter, createWebHistory, RouteRecordRaw, RouteRecordName } from "vue-router";
import InitRoute from "./initRoute";
import { BaseRouteList } from "./baseRoute";
const routes: Array<RouteRecordRaw> = [...BaseRouteList];
const baseRouteNames = ["Layout", "NotFound", "NoPromission", "Login"];
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
});
InitRoute(router);
export const resetRouter = () => {
  const allReoutes = router.getRoutes();
  for (let i = 0; i < allReoutes.length; i++) {
    const target = allReoutes[i];
    if (!baseRouteNames.includes(target.name as string)) router.removeRoute(target.name as RouteRecordName);
  }
};
export default router;
